Computer systems and/or operating systems execute multiple threads sequentially or in parallel. A thread is an execution across a portion of a program containing a series of instructions or steps to be performed. A thread may also be referred to as a portion of a program that can execute independently of other parts of the program. In a multi-threading architecture, two or more different parts of a program are executed simultaneously.
A variety of different computer systems handle multiple parallel requests for information or services. For example, web servers often receive multiple requests simultaneously or nearly simultaneously. Many of these requests can relate to similar or identical data, such as a particular web page or other information.
Computer systems typically include one or more caches, such as a data cache and an instruction cache. A cache is a high speed storage mechanism logically interposed between a lower and a higher member of a computer system's memory hierarchy. For example, a cache may be positioned between the computer system's main memory and processors. Typical programs executing on a computer system access the same data or instructions repeatedly. By storing this information in a cache, the overall performance of the computer system is enhanced because the information is retrieved from a faster cache rather than a slower storage device (such as a DRAM (Dynamic Random Access Memory) or a disk drive).
A typical cache stores data that has recently been requested by a program. When the program requests data or instructions, the computer system first checks the cache to see if the requested information is already in the cache. If so, the data is provided from the cache. Otherwise, the requested data is retrieved from a slower storage device, provided to the requesting program and stored in the cache for future data or instruction requests. When data is found in a cache, it is referred to as a “cache hit”; when data is not found in a cache, it is referred to as a “cache miss”. The effectiveness of a cache is determined by the cache “hit rate”, which is the rate (or frequency per number of attempts) at which data is found in the cache.
The effectiveness of a cache is typically diminished as a result of a context switch to a new thread. A context switch occurs when a multi-tasking system stops running one process (or thread) and starts running another process (or thread). After a particular thread has been running for some time, the associated cache contains data that is useful to that particular thread because threads tend to exhibit temporal locality in which they access the same data or instructions repeatedly. When a context switch to a new thread occurs, the cache data is replaced over time with data that is useful to the new thread. As the cache data is being replaced after a context switch, the hit rate of the cache is generally diminished.
Accordingly, it is desirable to reduce context switching in a computer system to enhance the effectiveness of a cache.